import request from '@/common/utils/request'
import {
	serv
} from '@/common/utils/config'

//获取查询状态列表
export function getQueryStatusList() {
	return request(serv.order + '/api/orders/getQueryStatus', {
		method: 'get'
	})
}

//获取用户各状态信息数量
export function getQueryUserStatusList(data) {
	return request(serv.order + '/api/orders/countByStatus', {
		method: 'get',
		data
	})
}
// 热卖商品
export function queryDefinedHotGoods(data) {
	return request(serv.portalent + '/api/shopingMall/queryDefinedHotGoods', {
		method: 'get',
		data:data
})
}
// 历史购买
export function queryHistoryPage(data) {
	return request(serv.order + '/api/historybuyproduct/queryHistoryPage', {
		method: 'post',
		data: data
	})
}

//获取订单列表
export function getOrderList(data) {
	return request(serv.order + '/api/orders/orderMasterList', {
		method: 'get',
		data: data
	})
}


//获取售后单列表
export function getAfterSaleList(data) {
	return request(serv.order + '/api/saleAfter/list', {
		method: 'post',
		data: data
	})
}

//发货
export function logisticsDelivery(logisticsName,data){
	return request(serv.order+'/api/saleAfter/logisticsDelivery?logisticsName='+logisticsName,{
		method:'POST',
		data:data
	})
}

//查询预购单
export function getPreOrder(data) {
	return request(serv.order + '/api/preorder', {
		method: 'get',
		data: data
	})
}

//查询收货地址列表
export function getAddressList(data) {
	return request(serv.order + '/api/receiverAddr/list', {
		method: 'get',
		data: data
	})
}

//设为默认地址
export function setDefault(data) {
	return request(serv.order + '/api/receiverAddr/setIsDefault', {
		method: 'get',
		data: data
	})
}

//删除收货地址
export function deleteAddr(data) {
	return request(serv.order + '/api/receiverAddr/delete', {
		method: 'get',
		data: data
	})
}

//新增收货地址
export function addAddr(data) {
	return request(serv.order + '/api/receiverAddr/add', {
		method: 'post',
		data: data
	})
}

//修改收货地址
export function updateAddr(data) {
	return request(serv.order + '/api/receiverAddr/update', {
		method: 'post',
		data: data
	})
}

//加载地区
export function loadAddr(data) {
	return request(serv.order + '/api/areas/getByCascade', {
		method: 'post',
		data: data
	})
}

//加载子地区
export function loadChildAddr(data) {
	return request(serv.order + '/api/areas/getByCascade', {
		method: 'post',
		data: data,
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
}

// 根据末级节点加载全部地区
export function loadChildAllAddr(data) {
	return request(serv.order + '/api/areas/getParentArea', {
		method: 'get',
		data: data,
	})
}

//获取订单金额运费等信息
export function getOrderFeeInfo(data) {
	return request(serv.order + '/api/preorder/calcFreight', {
		method: 'post',
		data: data,
		header: {
			'Content-Type': 'application/json;charset=UTF-8'
			// 'Cookie': 'x_domain=flsc.cloudcqc.com'
		}
	})
}

//创建订单
export function createOrder(data) {
	return request(serv.order + '/api/orders/create', {
		method: 'post',
		data: data,
		// header: {
		// 	'Content-Type': 'application/json;charset=UTF-8'
		// }
	})
}

// 获取用户积分列表
export function getIntegralList(data) {
	return request(serv.welfare + '/api/myIntegral/userIntegralList', {
		method: 'get',
		data: data
	})
}


// 取消订单
export function cancelOrder(data) {
	return request(serv.order + '/api/orders/cancel', {
		method: 'get',
		data: data
	})
}

// 获取订单状态字典
export function getAllStatus(data) {
	return request(serv.order + '/api/orders/getStatus', {
		method: 'get',
		data: data
	})
}

// 再来一单
export function buyAgain(data) {
	return request(serv.order + '/api/orders/buyAgain', {
		method: 'get',
		data: data
	})
}

// 下单前获取审批流用户
export function getApprovalFlowByUser(data) {
	return request(serv.order + '/api/orders/getApprovalFlowByUser', {
		method: 'post',
		data: data
	})
}

// 确认收货
export function confirmReceipt(data) {
	return request(serv.order + '/api/orders/confirmReceipt', {
		method: 'get',
		data: data
	})
}

// 获取物流信息
export function getLogistics(data) {
	return request(serv.order + '/api/orders/getLogistics', {
		method: 'get',
		data: data
	})
}

// 评价页面获取订单信息
export function getBySn(data) {
	return request(serv.order + '/api/orders/getBySn', {
		method: 'get',
		data: data
	})
}

// 查看评价
export function seeReview(data){
	return request(serv.order + '/api/review/getOrderReviews',{
		method:'get',
		data:data
	})
}


// 评价
export function addReview(data) {
	return request(serv.order + '/api/review/add', {
		method: 'post',
		data: data
	})
}

// 申请售后
export function applyAftersale(data) {
	return request(serv.order + '/api/saleAfter/continueSaleAfter', {
		method: 'get',
		data: data
	})
}

// 追加评价
export function addAddonReviewItem(data) {
	return request(serv.order + '/api/review/addAddonReviewItem', {
		method: 'post',
		data: data
	})
}

// 评价详情
export function getOrderReviews(data) {
	return request(serv.order + '/api/review/getOrderReviews', {
		method: 'get',
		data: data
	})
}

// 查询售后单详情
export function getAftersaleData(data) {
	return request(serv.order + '/api/saleAfter/getBySnData', {
		method: 'get',
		data: data
	})
}

// 获取售后单流转状态
export function getAftersaleState(data) {
	return request(serv.order + '/saleAfterLog/query/bySaleAfterSn', {
		method: 'get',
		data: data
	})
}

// 获取字典
export function getDict(data) {
	return request(serv.sysrest + '/api/dataDict/qryDataDictByDdfldList', {
		method: 'get',
		data: data
	})
}

// 获取公告日志
export function getLogList(data) {
	return request(serv.order + '/api/purchaseArticleLog/list', {
		method: 'get',
		data: data
	})
}

// 取消售后单
export function cancelAftersale(data) {
	return request(serv.order + '/api/saleAfter/cancel', {
		method: 'get',
		data: data
	})
}

// 查询发票列表
export function doLoadingInvoiceList(data){
	return request(serv.order+'/api/invoices/list',{
		method:'get',
		data:data
	})
}

// 新增发票
export function saveInvoice(data){
	return request(serv.order+'/api/invoices/add',{
		method:'POST',
		data:data
	})
}

// 更新发票
export function updateInvoice(data){
	return request(serv.order+'/api/invoices/update',{
		method:'POST',
		data:data
	})
}

// 发票删除
export function removeInvoice(data){
	return request(serv.order+'/api/invoices/remove',{
		method:'GET',
		data:data
	})
}

// 发票类型
export function getInvoiceType(data){
	return request(serv.order+'/api/invoices/getTypes',{
		method:'GET',
		data:data
	})
}

// 预算列表
export function getBudgetList(data){
	return request(serv.order+'/api/order/budget/list',{
		method:'GET',
		data:data
	})
}
// 预算配置
export function getBudgetConf(data){
	return request(serv.order+'/api/order/budget/getConfInfo',{
		method:'GET',
		data:data
	})
}
// 添加用户预算列表数据
export function addBudgetList(data){
	return request(serv.order+'/api/order/budget/addBudgetList',{
		method:'POST',
		data:data
	})
}
// 删除预算信息
export function removeUserBudgetInfo(data){
	return request(serv.order+'/api/order/budget/removeUserBudgetInfo',{
		method:'GET',
		data:data
	})
}
// 未关联商品预算
export function getCatalogNoRelationBudgetProducts(data) {
	return request(serv.order+'/api/order/budget/getCatalogNoRelationBudgetProducts',{
		method:'post',
		data:data
	})
}
// 添加/更新 预算到商品列表里
export function saveUserBudgetDetails(data,opt) {
	return request(serv.order+'/api/order/budget/saveUserBudgetDetails?opt='+opt,{
		method:'POST',
		data:data
	})
}
// 查看已关联的商品
export function seeBudgetInfoDetail(data){
	return request(serv.order+'/api/order/budget/seeBudgetInfoDetail',{
		method:'GET',
		data:data
	})
}
// 购买商品
export function bugGoods(data) {
	// return new Promise((resolve, reject) => {
	return request(serv.order+'/api/preorder/goOrderWithAmount', {
			method: 'post',
			data: data
		})
	// })
}
// 获取发货订单详情

// 加载发票配置
export function getInvoiceConf(data){
	return request(serv.order+'/api/invoicesConf/queryByMap',{
		method:'GET',
		data:data
	})
}
// 加载管理员发票
export function getAdminInvoice(data){
	return request(serv.order+'/api/invoices/getCurAdminInvoice',{
		method:'GET',
		data:data
	})
}

// 查询最低价商品
export function queryGoodsLowestPriceById(data){
	return request(serv.order+'/api/goods/queryGoodsLowestPriceById',{
		method:'GET',
		data:data
	})
}

// 查询订单数量
export function getCountByStatus(data) {
	return request(serv.order + '/api/orders/countByStatus', {
		method: 'get',
		data: data
	})
}

// 查询在途订单数量
export function countByShippedStatusV2(data) {
	return request(serv.order + '/api/orders/countByShippedStatusV2', {
		method: 'get',
		data: data
	})
}

// 查询待评论订单数量
export function getWaitReviewCount(data) {
	return request(serv.order + '/api/orders/countWaitReview', {
		method: 'get',
		data: data
	})
}

// 订单列表-供应商列表
export function orderMasterSupplierList(data) {
	return request(serv.order + '/api/orders/orderMasterSupplierList', {
		method: 'get',
		data: data
	})
}
// 评价管理-数量
export function evaluationCount(data) {
	return request(serv.order + '/api/orders/evaluationCount', {
		method: 'get',
		data: data
	})
}
// 黑名单
export function isBlackPermissionV2(data) {
	return request(serv.order + '/api/blackList/isBlackPermissionV2', {
		method: 'get',
		data: data
	})
}

// 猜你喜欢
export function qryGuessHotGoods(data) {
	return request(serv.order + '/api/order/goods/qryGuessHotGoods', {
		method: 'get',
		data: data
	})
}
